<?php

namespace app\merch\controller;

use think\Controller;
use think\Db;

class Main extends Controller {

    protected $sysset = array();
    protected $merchinfo = array();

     public function __construct(\think\App $app = null) {
        parent::__construct($app);
        $_GPC = input();
        if (session('merchinfo') == "") {
            if ($this->request->isAjax()) {
                json('error', 1, '登录超时！请刷新页面重新登录。');
            } else {
                $url = $this->request->domain(true) . '/merch/login';
                header('HTTP/1.1 303 See Other');
                header("Location: $url");
                exit;
            }
        } else {
            $this->merchinfo = unserialize(base64_decode(session('merchinfo')));
        }
        $_W['baseurl']=$this->request->domain(true);
         $_W['timestamp'] =time();
         $_W['sysset']=$this->sysset;
         $_W['sysset']['agent_level']=$this->merchinfo['agent_level'];
         $this->view->assign('_W', $_W);

        $this->sysset = get_sysset();
         $this->view->assign('sysset', $this->sysset);
        $this->view->assign('merchinfo', $this->merchinfo);
        $this->view->assign('platform_name', $this->sysset['basic']['platform_name']);
        $this->view->assign('logo', $this->sysset['basic']['logo']);
        if (cookie("formtoken") == "") {
            setcookie('formtoken', md5(rand(1, 999)), time() + 7200, '/');
        }
    }

}
